#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
class bit {
  using u64 = unsigned long long;
  u64 v = 0;
  // 辅助类，下标取值时的代理
  class Reference {
    u64 &val, msk;

   public:
    Reference(u64& val, u64 msk) : val(val), msk(msk) {}
    Reference& operator=(bool v) {
      if (v)
        val |= msk;
      else
        val &= ~msk;
      return *this;
    }
    Reference& operator^=(bool v) {
      if (v) val ^= msk;
      return *this;
    }
    operator bool() { return val & msk; }
  };

 public:
  // 按值初始化
  bit(u64 v = 0) : v(v) {}
  // 字符串初始化
  bit(const string& str) { *this = str; }
  // 按位初始化
  bit(const initializer_list<int>& indexes) { *this = indexes; }
  bit& operator=(u64 _v) {
    v = _v;
    return *this;
  }
  bit& operator=(const string& str) {
    v = 0;
    for (char c : str) v = (v << 1) | (c - '0');
    return *this;
  }
  bit& operator=(const initializer_list<int>& indexes) {
    v = 0;
    for (auto index : indexes) {
      v |= (1 << index);
    }
    return *this;
  }
  bit& operator+=(u64 x) { return v += x, *this; }
  bit& operator-=(u64 x) { return v -= x, *this; }
  bit& operator*=(u64 x) { return v *= x, *this; }
  bit& operator/=(u64 x) { return v /= x, *this; }
  bit& operator%=(u64 x) { return v %= x, *this; }
  bit& operator&=(u64 x) { return v &= x, *this; }
  bit& operator|=(u64 x) { return v |= x, *this; }
  bit& operator^=(u64 x) { return v ^= x, *this; }
  bit& operator<<=(u64 x) { return v <<= x, *this; }
  bit& operator>>=(u64 x) { return v >>= x, *this; }
  bit& operator++() { return ++v, *this; }
  bit operator++(int) { return bit(v++); }
  bit& operator--() { return --v, *this; }
  bit operator--(int) { return bit(v--); }

  Reference operator[](int index) { return Reference(v, 1 << index); }  // bit a; a[2] = 1;
  bool operator[](int index) const { return (v >> index) & 1; }

  operator u64() { return v; }
  string to_string() {
    if (v == 0) return "0";
    int len = 64 - countl_zero();
    string str(len, '0');
    for (u64 x = v; x; x >>= 1, len--)
      if (x & 1) str[len - 1] = '1';
    return str;
  }
  bool test(int index) { return (v >> index) & 1; }
  template <typename... Args>
  bool test_all(Args... index) {
    return (test(index) && ...);
  }
  template <typename... Args>
  bool test_any(Args... index) {
    return (test(index) || ...);
  }
  template <typename... Args>
  bool test_none(Args... index) {
    return (!test(index) && ...);
  }
  // 获取最低位的 1, lsb = Lowest Significant Bit
  u64 lsb() { return v & -v; }
  bit& clear_lsb() { return v &= (v - 1), *this; }

  unsigned countl_zero() { return v == 0 ? 64 : __builtin_clzll(v); }
  unsigned countr_zero() { return v == 0 ? 64 : __builtin_ctzll(v); }
  unsigned countl_one() { return v == 0 ? 0 : __builtin_clzll(~v); }
  unsigned countr_one() { return v == 0 ? 0 : __builtin_ctzll(~v); }
  unsigned count_one() { return __builtin_popcountll(v); }
  template <typename... Args>
  bit set(Args... index) {
    return v | ((1ull << index) | ...);
  }
  template <typename... Args>
  bit reset(Args... index) {
    return v & ~((1ull << index) | ...);
  }
  template <typename... Args>
  bit flip(Args... index) {
    return v ^ ((1ull << index) | ...);
  }
  // 清空低 n 位
  bit clear(int n) { return v & ~((1ull << (n + 1)) - 1); }
  // 设置低 n 位
  bit fill(int n) { return v | ((1ull << (n + 1)) - 1); }
  // 判断是 2 的幂次
  bool is_single_bit() { return v != 0 && (v & (v - 1)) == 0; }
  // 不小于 x 的最小的二的整数次幂
  bit bit_ceil() { return 1ull << (64 - __builtin_clzll(v - 1)); }  // 7 -> 8   16 -> 16   100 -> 128
  // 只包含 1 的有效宽度
  unsigned bit_width() {
    if (v == 0) return 0;
    return 64 - countl_zero() - countr_zero();
  }
  // 向左循环旋转
  bit rotl(unsigned s, unsigned width = 64) {
    s %= width;
    u64 mask = (1ull << width) - 1;
    return (v >> (width - s)) | ((v << s) & mask);
  }
  // 向右循环旋转
  bit rotr(unsigned s, unsigned width = 64) {
    s %= width;
    u64 mask = (1ull << s) - 1;
    return ((v & mask) << (width - s)) | (v >> s);
  }
  bool is_odd() { return v & 1; }
  bool is_even() { return !(v & 1); }
  friend istream& operator>>(istream& is, bit& x) { return is >> x.v; }
  friend ostream& operator<<(ostream& os, const bit& x) { return os << x.v; }
};
int main() {
  //  101  5 -> 1
  //  110  6 -> 0
  //  110  6 -> 2
  // 1000  7
  //            3
  // n -> set kth as 1
  //      clear [0,k) as 0
  bit n;
  int q;
  cin >> n >> q;
  unsigned ans = 0;
  while (q--) {
    int k;
    cin >> k;
    k--;
    bit next_n = n.set(k);
    unsigned next_n = n | (1 << k);
    if (next_n != n) {
      next_n &= ~((1 << k) - 1);
    }
    ans += next_n - n;
    n = next_n;
  }
  cout << ans << endl;
}